/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.meraklisina.latexeditor;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBoxMenuItem;

/**
 *Menuitem that holds toolbars information. If toolbar is visible then this menuitem is checked.
 * @author Serkan
 */
public class LatexToolbarMenuItem extends JCheckBoxMenuItem implements ActionListener{
    private LatexToolBar toolbar=null;
    public LatexToolbarMenuItem(LatexToolBar toolbar){
        super(toolbar.getName());
        this.toolbar = toolbar;
        System.out.println("toolbar.getName()>"+toolbar.getName());
        //this.set.setText(toolbar.getName());
        this.setSelected(toolbar.isAvailable());
        this.addActionListener(this);
    }

    public void actionPerformed(ActionEvent arg0) {
        ToolBarHandler tbh=ToolBarHandler.getHandler();

        if(this.isSelected()){
            tbh.AddToolBarToPanel(toolbar);
        }else{
            tbh.RemoveToolBarFromPanel(toolbar);
        }
        
    }
}
